package createType.example.maze;

import java.util.ArrayList;
import java.util.List;

public class Maze {
	
public List<Room> rooms = new ArrayList<Room>();
	
	private  Room start;
	private Room[] exits;
	
	public Maze(Room s, Room e){
		this.start = s;
		this.exits = new Room[]{e};//好奇怪啊 = {e} error:Array constants can only be used in initializers
	}
	
	public Maze(Room s,Room[] es){
		this.start = s;
		this.exits = es;
	}
	
	public Room getStart(){
		return start;
	}
	public Room[] getExit(){
		return exits;
	}
	
	public void printMaze(){
		System.out.println("Start: "+ start.RoomNo);
		System.out.println("----------------------------------------------------------------------------------------");
		System.out.print("Exits: ");
		for(Room e:exits){
			System.out.print(e.RoomNo+"     ");
		}
		System.out.print("\n----------------------------------------------------------------------------------------");
		
		for(Room r:rooms){
			System.out.print("\n"+r.RoomNo);
			for(int i = 0;i<4;i++){
				System.out.print(Direction.values()[i]+":"+r.getSide(Direction.values()[i]).getClass().getSimpleName());
				if(r.getSide(Direction.values()[i]).getClass().getSimpleName().equals("Door")){
					System.out.print("( from "+((Room)((Door)r.getSide(Direction.values()[i])).getPath().getNodes().get(0)).RoomNo);
					System.out.print(" to "+((Room)((Door)r.getSide(Direction.values()[i])).getPath().getNodes().get(1)).RoomNo+" )");
				}
				System.out.print(";");
			}
		}
		System.out.println("\n"+"----------------------------------------------------------------------------------------");
	}
	
}
